package com.pearadmin.pro.modules.stu.rest;

import com.pearadmin.pro.modules.stu.domain.StuOrderDeposit;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.stu.domain.StuOrderDeposit;
import  com.pearadmin.pro.modules.stu.param.StuOrderDepositRequest;
import  com.pearadmin.pro.modules.stu.service.StuOrderDepositService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 订单定金信息Controller
 *
 * @author chenJian
 * @date 2021-09-09
 */
@Api(tags = {"订单定金信息"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"stu/stuOrderDeposit")
public class StuOrderDepositController extends BaseController
{
    @Resource
    private StuOrderDepositService stuOrderDepositService;

    /**
     * 查询订单定金信息列表
     *  @param request 查询参数
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "订单定金信息列表")
    @ApiOperation(value = "订单定金信息列表")
    public Result<StuOrderDeposit> list(StuOrderDepositRequest stuOrderDepositRequest)
    {
        return success(stuOrderDepositService.page(stuOrderDepositRequest));
    }


    /**
     * 新增保存订单定金信息
     * @param stuOrderDeposit 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增订单定金信息")
    @ApiOperation(value = "新增订单定金信息")
    public Result save(@RequestBody StuOrderDeposit stuOrderDeposit)
    {
        return auto(stuOrderDepositService.saveOrUpdate(stuOrderDeposit));
    }

    /**
     * 查询订单定金信息详情
     *
     * @param id 订单定金信息ID
     * @return 订单定金信息
     */
    @GetMapping("/selectById")
    @Log(title = "查询订单定金信息详情")
    @ApiOperation(value = "查询订单定金信息详情")
    public Result<StuOrderDeposit> selectById(@RequestParam Long id)
    {
        return success(stuOrderDepositService.selectStuOrderDepositById(id));
    }



    /**
     * 修改保存订单定金信息
     * @param stuOrderDeposit 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改订单定金信息")
    @ApiOperation(value = "修改订单定金信息")
    public Result update(@RequestBody StuOrderDeposit stuOrderDeposit)
    {
        return auto(stuOrderDepositService.saveOrUpdate(stuOrderDeposit));
    }


    /**
     * 删除保存订单定金信息
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除订单定金信息")
    @ApiOperation(value = "删除订单定金信息")
    public Result remove(@RequestParam Long id)
    {
        return auto(stuOrderDepositService.removeById(id));
    }

    /**
    * 批量删除订单定金信息
    * @param ids 批量删除
    * @return {@link Result}
    */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除订单定金信息")
    @ApiOperation(value = "批量删除订单定金信息")
    public Result removeBatch(@RequestParam List<Long> ids){
        return auto(stuOrderDepositService.removeByIds(ids));
    }

}
